package zhouzhouyongche.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zhouzhouyongche.dao.CityDao;
import zhouzhouyongche.dao.PassengerStationDao;
import zhouzhouyongche.model.City;
import zhouzhouyongche.model.PassengerStation;
import zhouzhouyongche.service.PassengerStationService;

@Service
public class PassengerStationServiceImpl implements PassengerStationService {

	@Autowired
	private PassengerStationDao passengerStationDao;
	
	@Autowired
	private CityDao cityDao;

	@Override
	public List getPassengerStation(int cityId) {
		return cityDao.getPassengerStation(cityId);
	}

	@Override
	public List getAllPassengerStation() {
		
		return null;
	}

	@Override
	public void addPassengerStation(int cityId, String passengerStationName) {
		City city = cityDao.get(cityId);
		PassengerStation p = new PassengerStation();
		p.setPassengerStationName(passengerStationName);
		
		city.getPassengerStationList().add(p);
		passengerStationDao.save(p);
		cityDao.update(city);
	}
	
	
}
